package swing_framework; 

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class MainFrame {
       static private JFrame mainWindow;
       private static MainFrame instance;
       
       private final String title="Data Visulization";
       private int windowHeight=600;
       private int windowWidth=800;
       private int originX=100;
       private int originY=100;
       
       private JPanel bottomPanel;
       private JPanel midPanel;
       
       
       private MainFrame(){
    	   
       }
       public static MainFrame getInstance(){
    	   synchronized (MainFrame.class) {
			if (instance==null) {
				synchronized (MainFrame.class) {
					instance=new MainFrame();
				}
			}
		}
    	   return instance;
       }
       
       public void setup(){
    	   mainWindow=new JFrame(title);
    	   mainWindow.setBounds(originX, originY, windowWidth, windowHeight);
    	   mainWindow.setLayout(new BorderLayout());
    	   /*midPanel=new DataPanel().createDataPanel();*/
    	   VisulizationPanel vPanel = new VisulizationPanel();
    	   
    	   midPanel=vPanel.createVisualizationPanel();
    	   midPanel.setBackground(Color.BLACK);
    	   midPanel.setPreferredSize(new Dimension(550,600));
    	   midPanel.setBorder(BorderFactory.createEtchedBorder());
    	   
    	  
    	   
    	   bottomPanel=new ParameterPanel().createParameterPanel(vPanel.get3DModel());
    	   bottomPanel.setBackground(Color.RED);
    	   bottomPanel.setPreferredSize(new Dimension(1366,118));
    	   bottomPanel.setBorder(BorderFactory.createEtchedBorder());
    	   mainWindow.getContentPane().add(bottomPanel,BorderLayout.SOUTH);
    	   mainWindow.getContentPane().add(midPanel,BorderLayout.CENTER);
    	   mainWindow.addWindowListener(new windowEventHandler());
    	   mainWindow.setExtendedState(JFrame.MAXIMIZED_BOTH);
    	   mainWindow.setVisible(true);
    	   mainWindow.setResizable(false);
       }
       
       class windowEventHandler extends WindowAdapter{
    	   public void windowClosing(WindowEvent e){
    		   System.out.println("Exit");		
   			   System.exit(0);
    	   }
       }
}
 